package com.hunan.api.catv.entity.enums;

import cn.hutool.core.util.StrUtil;

import java.util.Map;

/**
 * @author jiang zhuan
 * @version 1.0
 * @description 描述
 * @date 2021/11/25 0025
 * @package com.hunan.api.catv.entity.enums
 * @company 湖南有线
 */
public enum SmartFamilyMsgTemplateEnum {

    shareHome0("shareHome", 0, "{ownerNickName}在{msgTime}邀请你加入{homeName}"),
    shareHome1("shareHome", 1, "{ownerNickName}在{msgTime}取消你加入{homeName}"),
    shareHome2("shareHome", 2, "{nickName}在{msgTime}加入了{homeName}"),
    shareHome3("shareHome", 3, "{nickName}在{msgTime}退出了{homeName}"),

    shareDevice0("shareDevice", 0, "{ownerNickName}在{msgTime}给你共享了一个{deviceName}"),
    shareDevice1("shareDevice", 1, "{ownerNickName}在{msgTime}取消{deviceName}的共享"),
    shareDevice2("shareDevice", 2, "{nickName}在{msgTime}接受了你共享的{deviceName}"),
    shareDevice3("shareDevice", 3, "{nickName}在{msgTime}取消了你共享的{deviceName}"),

    alarm("alarm", 0, "{alarmTime} {deviceName}：{describe}");

    private final String name;

    private final Integer state;

    private final String template;

    SmartFamilyMsgTemplateEnum(String name, Integer state, String template) {
        this.name = name;
        this.state = state;
        this.template = template;
    }

    public String getName() {
        return name;
    }

    public Integer getState() {
        return state;
    }

    public String getTemplate() {
        return template;
    }

    public static String getMsg(String name, Integer state, Map<String,String> params) {
        SmartFamilyMsgTemplateEnum[] values = SmartFamilyMsgTemplateEnum.values();
        for (SmartFamilyMsgTemplateEnum value : values) {
            if (value.getName().equals(name) && value.getState().equals(state)) {
                return StrUtil.format(value.getTemplate(), params);
            }
        }
        return null;
    }

}
